package com.fjrcloud.exception.handler;

import com.fjrcloud.entity.ResponseBean;
import com.fjrcloud.entity.ResponseFactory;
import com.fjrcloud.exception.BusinessException;
import com.fjrcloud.utils.StatusUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 林圣坚 on 2016/9/3.
 */
@ControllerAdvice
public class BusinessExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public ResponseBean baseException(Exception e) throws Exception {
        return ResponseFactory.getResponseBean(StatusUtils.Fail, e.getMessage());
    }
}
